<div id="headerPage">
    <span>Registrar Empréstimo</span>
</div>
<div style="text-align:left;" id="box">
    <form style="width:550px; background-color: #f0f0f0; padding:15px 0px 15px 15px; border:1px solid;" class="form2" method="POST" action="">
        <label style="padding-right:10px;"><span>Requisitante:</span>
            <input readonly="readonly" style="width:250px;" type="text" name="nome_requisitante" value="<?php echo $requisitante['nome_usuario']; ?>">
            <a class="btNoMaginAndLink" href="index.php?modulo=emprestimos&page=visualizar&key=<?php echo $_GET['key'] ?>">Empréstimos</a>
        </label><br/>
        <label><span>Responsável:</span>
            <input readonly="readonly" style="width:250px" type="text" name="nome_responsavel" value="<?php echo $sessao->getVar('usuario')->nome_usuario; ?>">
        </label><br/>
        <label><span>Data Inicial:</span>
            <input readonly="readonly" style="width:90px" type="text" name="dt_inicial_emprestimo" value="<?php echo date('d/m/Y'); ?>">
        </label><br/>
        
        <fieldset style="margin-right:20px;">
            <legend align="right">
                <a onclick="gambi()" class="btNoMaginAndLink open-linkMat" title="Adicionar Item" href="index.php?modulo=emprestimos&page=gerar&add-mat=1&key=<?php echo $_GET['key'] ?>">Adicionar</a>
            </legend>
            <table class="table" style="margin-top:5px;">
                <thead>
                    <tr>
                        <th width="300px">Item</th>
                        <th width="50px">Qtd</th>
                        <th width="130px">Entrega</th>
                        <th></th>
                    </tr>
                </thead>
                <tbody>
                    <?php
                    if ($sessao->getVar('mat') != null) {
                        $i=0;
                        foreach ($sessao->getVar('mat') as $item){
                            if ($item['dt_final'] == null){
                               $data = "Sem Prazo";
                            }else{
                                $data = Utils::formatDateTime($item['dt_final']);
                               
                            }
                            
                            $color = ($i % 2) == 0 ? '#ffffff' : '#e0e0e0';
                            echo "<tr bgcolor='$color'>
                                    <td style='padding-left:4px'>{$item['descricao_item']}</td>
                                    <td>{$item['quantidade_item']}</td>
                                    <td>{$data}</td>
                                    <td align=center ><a title='Excluir item' href='index.php?modulo=emprestimos&page=gerar&nome={$item['descricao_item']}&del=1'>
                                        <img src='app.misc/images/ico_delete.png'></a></td> 
                                </tr>"; 

                            $i++;          
                        }
                    }else{
                        echo "<tr bgcolor=#ffffff align=center >
                              <td colspan=4>Nenhum item Adicionado!</td>
                              </tr>";
                    }
                    ?>
                </tbody>
            </table>
        </fieldset>
        
        <input type="submit" name="save" value="Salvar"/>
        <input type="button" name="save" value="Cancelar" onclick="javascript:location='index.php?modulo=usuarios&page=visualizar&empCancel=1'"/>
    </form>
</div>
<div style="text-align: left;" width="520" id="janela-dialogMat">
    <form id="form-dialogMat" method="POST" action="">
        <label>
            <span>Material</span>
            <input style="width:300px; margin-bottom:30px" type="text" name="item">
        </label>
        <label>
            <span>Qtd</span>
            <input style="width:50px;" type="text" name="item_qtd">
        </label><br/>
        <fieldset>
            <legend>
                <label>
                    <span>Habilitar</span>
                    <input onclick="habilita(this)" id="habilitar" style="margin-bottom:5px;" type="checkbox" name="">
                </label>
                <label>
            </legend>
                    <span>Data</span>
                    <input id="date" style="width:100px;" readonly="readonly" class="datepicker" type="text" name="item_entrega" value="00/00/00">
                </label>
                <select class="select" disabled="disabled" name="hora_entrega">
                <?php for ($i=0; $i < 24; ++$i){
                    echo '<option value='.$i.'>'.str_pad($i, 2, '0', STR_PAD_LEFT).'</option>'; 
                    }
                ?>
                </select>
                <span>:</span>
                <select class="select" disabled="disabled" name="minuto_entrega">
                <?php for ($i=0; $i < 60; $i = $i + 15){
                    echo '<option value='.$i.'>'.str_pad($i, 2, '0', STR_PAD_LEFT).'</option>'; 
                    }        
                ?>
                </select>
        </fieldset>
    </form>
</div>
